;(function($,window){
	
	$.extend({
		
		addCookie:function(key,value,day,path,domain)
		{
				var index = window.location.pathname.lastIndexOf("/");
				var currentPath = window.location.pathname.slice(1, index);
				path = path || currentPath;
				
				//2.处理默认保存的domain
				domain = domain || document.domain;
				//3.处理默认的过期时间
				if(!day)
				{
					document.cookie = key+"="+value+";path="+path+";domain="+domain+";";
				}else
				{
					var date = new Date();
					date.setDate(date.getDate() + day);
					document.cookie = key+"="+value+";expires="+date.toGMTString()+";path="+path+";domain="+domain+";";
					
					
				}
		
			
		},
		getCookie:function(key)
		{
			var res = document.cookie.split(";");
			for(var i=0; i < res.length; i++)
			{
				//console.log(res[i]);
				var temp = res[i].split("=");
				//console.log(temp);
				if(temp[0].trim() === key)
				{
					return (temp[1]);
				}
				
			};
			
		},
		
		//console.log(getCookie("name"));
		
		//默认情况下只能删除默认路劲中保存的cookie，如果想删除指定路劲保存的cookie，那么必须在删除的时候指定路劲才可以
		delCookie:function(key,path)
		{
			addCookie(key,getCookie(key),-1,path);
		}
		
	});
	
})(jQuery,window);